package com.zeus.controller;

import com.zeus.pojo.Category;
import com.zeus.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @author 冯扬龙
 * @date 2021/4/16 20:46
 */
@Controller
public class IndexController {
    @Autowired
    private CategoryService categoryService;

//点击登录按钮以后进到首页，自动加载里面的商品类别信息
    @RequestMapping("/index")
    public ModelAndView index()
    {
        ModelAndView modelAndView=new ModelAndView();
        modelAndView.setViewName("index");
        //查询类别 传到index
        List<Category> categoryList= categoryService.selectCategoryList();
        modelAndView.addObject("categoryList",categoryList);
        return modelAndView;
    }
}
